package com.test.SocketDemo;

import java.io.*;
import java.net.ServerSocket;
import java.net.Socket;

/**
 * ${DESCRIPTION}
 *
 * @author muxiaoyu
 * @create 2017/06/09 9:27
 **/
public class RemoteObjectServer {
    public static void main(String[] args) throws Exception {
        ServerSocket serverSocket = new ServerSocket(6655);
        Socket clientSocket = serverSocket.accept();
        OutputStream outputStream = clientSocket.getOutputStream();
        InputStream inputStream = clientSocket.getInputStream();
        ObjectInputStream objectInputStream = new ObjectInputStream(inputStream);
        ModObject o = (ModObject) objectInputStream.readObject();
        System.out.println(o);
        PrintWriter printWriter = new PrintWriter(new OutputStreamWriter(outputStream));
        printWriter.write("已经接收到对象！");
        printWriter.flush();
        outputStream.close();
        inputStream.close();
    }
}
